<template>
  <div id="app">
    <h3>-----------这是主页-----------</h3>
    <span>欢迎：{{loginName}}</span>
    <!-- <a href="" @click.prevent="back()">返回首页</a> -->
    <ul>
      <li v-for="(item,index) in list">
        <router-link :to="'/detail/'+item.aid">{{item.title}}</router-link>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      msg: "Welcome to Your Vue.js App",
      loginName: "",
      list: []
    };
  },
  methods: {},
  // 加载完成
  mounted() {
    console.log(this.$route.query);
    this.loginName = this.$route.query.username;
    var api =
      "http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1";
    this.$http.get(api, { params: { id: 9, name: "hu" } }).then(
      res => {
        this.list = res.body.result;
      },
      function(err) {
        console.log(err);
      }
    );
    var api = "http://ft.wangruixiang.site/PaymentDetails/QueryPageData";
    this.$http
      .post(
        api,
        { PageIndex: -1, PageSize: 10, Entity: {} },
        { emulateJSON: true }
      )
      .then(
        res => {
          this.list = res.body.result;
        },
        function(err) {
          console.log(err);
        }
      );
  },
  beforeDestroy() {
    /*页面销毁的时候要保存一些数据，就可以监听这个销毁的生命周期函数*/
    console.log("实例销毁之前");
  },
  destroyed() {
    console.log("实例销毁完成");
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
h1,
h2 {
  font-weight: normal;
}

ul {
  list-style: unset;
  padding: 0;
}

li {
  display: block;
  margin-bottom: 10px;
}

a {
  color: #42b983;
}
</style>
